import java.util.ArrayList;

public class Block extends Statement{

	public ArrayList<Statement> statements;
	
	public Block(){
		
		statements = new ArrayList<Statement>();
		
	}
	
	public void add(Statement st){
		
		statements.add(st);
		
	}
	
	
	public String toString(){
		
		String result = "Block \n";
		String tbr = "";
		
		for(Statement st : statements)
		{
			tbr += "| "+st.toString();
		}
		
		if(tbr.length() > 0)
			for( String s: tbr.split("\n"))
			{
				result += "| " +s + "\n";
			}
		return result;
		
	}

	public void check() throws SemanticException {
		
		for(Statement st : statements){
			
			st.methodName = this.methodName;
			st.check();
			
		}
		
	}

	public boolean willReturn() {
		
		boolean result = false;
		for(Statement st: statements)
			result |= st.willReturn();
		return(result);
		
	}
	
}
